import 'dart:core';

import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_task_record_by_unit_id_entity.dart';

///单元-》任务
class AnnualHazardPlanTaskController extends GetxController {
  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();

  /// 筛选右侧栏控制Key
  final riskRightScaffoldKey = GlobalKey<ScaffoldState>();

  String riskUnitName = '';
  String planId = '';
  String unitId = '';

  @override
  void onInit() {
    super.onInit();
    planId = Get.arguments['planId'] as String;
    unitId = Get.arguments['unitId'] as String;
    riskUnitName = Get.arguments['riskUnitName'] as String; //单元
  }

  Future<List<GetTaskRecordByUnitIdEntity>> getTaskRecordByUnitId(int index, int size, {String? search}) async {
    final res = await HttpUtil().generateGetRequest<List<GetTaskRecordByUnitIdEntity>>(
      Interface.getTaskRecordByUnitId,
      queryParameters: {
        'planId': planId,
        'unitId': unitId,
      },
    ).execute();
    List<GetTaskRecordByUnitIdEntity>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
      }
    });
    return list!;
  }
}
